<?php

namespace app\admin\controller;

use app\common\model\Webset as WebsetModel;
use think\Request;

class Webset extends Common
{
    //站点设置
    public function index(Request $request)
    {
        if ($request->isPost()) {
            $WebsetM = WebsetModel::find() ?: new WebsetModel();
            $data['content'] = json_encode($request->post());
            $res = $WebsetM->save($data);
            if ($res) {
                //清除缓存
                cache('webset', NULL);
                $this->success('操作成功', '/admin/webset/index');
            } else {
                $this->error('错误');
            }
            exit();
        }
        return view();
    }
}
